package com.ruoyi.supermarket.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.supermarket.domain.Yfpay;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.supermarket.domain.Xqsale;
import com.ruoyi.supermarket.service.IXqsaleService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 销售详情Controller
 * 
 * @author ruoyi
 * @date 2024-05-28
 */
@RestController
@RequestMapping("/supermarket/xqsale")
public class XqsaleController extends BaseController
{
    @Autowired
    private IXqsaleService xqsaleService;

    /**
     * 查询销售详情列表
     */
    @PreAuthorize("@ss.hasPermi('supermarket:xqsale:list')")
    @GetMapping("/list")
    public AjaxResult list(Xqsale xqsale)
    {

        List<Xqsale> list = xqsaleService.selectXqsaleList(xqsale);
        return success(list);
    }

    @PreAuthorize("@ss.hasPermi('supermarket:xqsale:list')")
    @GetMapping("/listprofit")
    public TableDataInfo listProfit(Xqsale xqsale)
    {
        startPage();
        List<Xqsale> list = xqsaleService.selectXqsaleListProfit(xqsale);
        return getDataTable(list);
    }



    /**
     * 导出销售详情列表
     */
    @PreAuthorize("@ss.hasPermi('supermarket:xqsale:export')")
    @Log(title = "销售详情", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Xqsale xqsale)
    {
        List<Xqsale> list = xqsaleService.selectXqsaleList(xqsale);
        ExcelUtil<Xqsale> util = new ExcelUtil<Xqsale>(Xqsale.class);
        util.exportExcel(response, list, "销售详情数据");
    }

    /**
     * 获取销售详情详细信息
     */
    @PreAuthorize("@ss.hasPermi('supermarket:xqsale:query')")
    @GetMapping(value = "/{xqsaleId}")
    public AjaxResult getInfo(@PathVariable("xqsaleId") Long xqsaleId)
    {
        return success(xqsaleService.selectXqsaleByXqsaleId(xqsaleId));
    }

    /**
     * 新增销售详情
     */
    @PreAuthorize("@ss.hasPermi('supermarket:xqsale:add')")
    @Log(title = "销售详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Xqsale xqsale)
    {
        return toAjax(xqsaleService.insertXqsale(xqsale));
    }

    /**
     * 修改销售详情
     */
    @PreAuthorize("@ss.hasPermi('supermarket:xqsale:edit')")
    @Log(title = "销售详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Xqsale xqsale)
    {
        return toAjax(xqsaleService.updateXqsale(xqsale));
    }

    /**
     * 删除销售详情
     */
    @PreAuthorize("@ss.hasPermi('supermarket:xqsale:remove')")
    @Log(title = "销售详情", businessType = BusinessType.DELETE)
	@DeleteMapping("/{xqsaleIds}")
    public AjaxResult remove(@PathVariable Long[] xqsaleIds)
    {
        return toAjax(xqsaleService.deleteXqsaleByXqsaleIds(xqsaleIds));
    }
}
